<?php

class Member extends AppModel {
	var $name = 'Member';
	var $useTable = 'member_info';
	var $primaryKey = 'id';
	//wang.wei add 2012/03/1
	var $htmlValid = array();
	
	//wang.wei update 2012/02/27
	var $encrypt_col = array(
		'name_kanji', 'name_kana', 'pwd_remain_answer', 'email', 'note', 'withdraw_reason', 'address_location_other',
			 'tel', 'login_pwd_confirm');
	
	var $displayField = 'name';
	var $belongsTo = array(
		'SysParams1'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"nationality_id" = "SysParams1"."id" AND "SysParams1"."kbn" = \'nationality_id\' and "SysParams1"."id"'
	), 'SysParams2'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"mailmaga_flg" = "SysParams2"."id" AND "SysParams2"."kbn"=\'mailmaga_flg\' and "SysParams2"."id"'
	), 'SysParams3'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"address_location_id"="SysParams3"."id" AND "SysParams3"."kbn"=\'city_id\' and "SysParams3"."id"'
	), 'SysParams4'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"sex_id"="SysParams4"."id" AND "SysParams4"."kbn"=\'sex_id\' and "SysParams4"."id"'
	), 'SysParams5'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"address_nation_id"="SysParams5"."id" AND "SysParams5"."kbn"=\'country_id\' and "SysParams5"."id"'
// 	), 'SysParams6'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"work_type_id1"="SysParams6"."id" AND "SysParams6"."kbn"=\'interest_work_type_id\' and "SysParams6"."id"'
// 	), 'SysParams7'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"work_type_id2"="SysParams7"."id" AND "SysParams7"."kbn"=\'interest_work_type_id\' and "SysParams7"."id"'
// 	), 'SysParams8'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"work_type_id3"="SysParams8"."id" AND "SysParams8"."kbn"=\'interest_work_type_id\' and "SysParams8"."id"'
// 	), 'SysParams9'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"interest_work_type_id1"="SysParams9"."id" AND "SysParams9"."kbn"=\'interest_work_type_id\' and "SysParams9"."id"'
// 	), 'SysParams10'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"interest_work_type_id2"="SysParams10"."id" AND "SysParams10"."kbn"=\'interest_work_type_id\' and "SysParams10"."id"'
// 	), 'SysParams11'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"interest_work_type_id3"="SysParams11"."id" AND "SysParams11"."kbn"=\'interest_work_type_id\' and "SysParams11"."id"'
	), 'SysParams12'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"work_status_id"="SysParams12"."id" AND "SysParams12"."kbn"=\'work_status_id\'  and "SysParams12"."id"'
// 	), 'SysParams13'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"education_id"="SysParams13"."id" AND "SysParams13"."kbn"=\'education_id\' and "SysParams13"."id"'
// 	), 'SysParams14'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"language_jp_id"="SysParams14"."id" AND "SysParams14"."kbn"=\'language_id\' and "SysParams14" ."id"'
// 	), 'SysParams15'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"language_ch_gd_id"="SysParams15"."id" AND "SysParams15"."kbn"=\'language_id\' and "SysParams15" ."id"'
// 	), 'SysParams16'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"language_en_id"="SysParams16"."id" AND "SysParams16"."kbn"=\'language_id\' and "SysParams16" ."id"'
// 	), 'SysParams17'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"language_other_id1"="SysParams17"."id" AND "SysParams17"."kbn"=\'language_id\' and "SysParams17"."id"'
// 	), 'SysParams18'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"language_ch_bj_id"="SysParams18"."id" AND "SysParams18"."kbn"=\'language_id\' and "SysParams18"."id"'
// 	), 'SysParams19'=>array(
// 		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"language_other_id2"="SysParams19"."id" AND "SysParams19"."kbn"=\'language_id\' and "SysParams19" ."id"'
	), 'SysParams20'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"pwd_remain_id"="SysParams20"."id" AND "SysParams20"."kbn"=\'password_question_id\' and "SysParams20"."id"'
	), 'SysParams21'=>array(
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"new_mail_flg"="SysParams21"."id" AND "SysParams21"."kbn"=\'mailmaga_flg\' and "SysParams21" ."id"'
	), 'SysParams22'=>array( //ツバサ 2012-02-21 転職意欲
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"change_work_will"="SysParams22"."id" AND "SysParams22"."kbn"=\'change_work_will\' and "SysParams22"."id"'
	), 'SysParams23'=>array( //ツバサ 2012-02-22 希望勤務地1
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_work_location1"="SysParams23"."id" AND "SysParams23"."kbn"=\'hope_work_location\' and "SysParams23"."id"'
	), 'SysParams24'=>array( //ツバサ 2012-02-22 希望勤務地2
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_work_location2"="SysParams24"."id" AND "SysParams24"."kbn"=\'hope_work_location\' and "SysParams24"."id"'
	), 'SysParams25'=>array( //ツバサ 2012-02-22 希望勤務地3
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_work_location3"="SysParams25"."id" AND "SysParams25"."kbn"=\'hope_work_location\' and "SysParams25"."id"'
	), 'SysParams26'=>array( //ツバサ 2012-02-22 留学経験１国名
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu1_nation"="SysParams26"."id" AND "SysParams26"."kbn"=\'country_id\' and "SysParams26"."id"'
	), 'SysParams27'=>array( //ツバサ 2012-02-22 留学経験１期間
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu1_period"="SysParams27"."id" AND "SysParams27"."kbn"=\'overseas_edu_period\' and "SysParams27"."id"'
	), 'SysParams28'=>array( //ツバサ 2012-02-22 留学経験１目的
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu1_purpose"="SysParams28"."id" AND "SysParams28"."kbn"=\'overseas_edu_purpose\' and "SysParams28"."id"'
	), 'SysParams29'=>array( //ツバサ 2012-02-22 留学経験2国名
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu2_nation"="SysParams29"."id" AND "SysParams29"."kbn"=\'country_id\' and "SysParams29"."id"'
	), 'SysParams30'=>array( //ツバサ 2012-02-22 留学経験2期間
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu2_period"="SysParams30"."id" AND "SysParams30"."kbn"=\'overseas_edu_period\' and "SysParams30"."id"'
	), 'SysParams31'=>array( //ツバサ 2012-02-22 留学経験2目的
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu2_purpose"="SysParams31"."id" AND "SysParams31"."kbn"=\'overseas_edu_purpose\' and "SysParams31"."id"'
	), 'SysParams32'=>array( //ツバサ 2012-02-22 留学経験3国名
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu3_nation"="SysParams32"."id" AND "SysParams32"."kbn"=\'country_id\' and "SysParams32"."id"'
	), 'SysParams33'=>array( //ツバサ 2012-02-22 留学経験3期間
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu3_period"="SysParams33"."id" AND "SysParams33"."kbn"=\'overseas_edu_period\' and "SysParams33"."id"'
	), 'SysParams34'=>array( //ツバサ 2012-02-22 留学経験3目的
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_edu3_purpose"="SysParams34"."id" AND "SysParams34"."kbn"=\'overseas_edu_purpose\' and "SysParams34"."id"'
	), 'SysParams35'=>array( //ツバサ 2012-02-22 外国勤務１国名
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work1_nation"="SysParams35"."id" AND "SysParams35"."kbn"=\'country_id\' and "SysParams35"."id"'
	), 'SysParams36'=>array( //ツバサ 2012-02-22 外国勤務１期間
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work1_period"="SysParams36"."id" AND "SysParams36"."kbn"=\'overseas_work_period\' and "SysParams36"."id"'
	), 'SysParams37'=>array( //ツバサ 2012-02-22 外国勤務１目的
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work1_position"="SysParams37"."id" AND "SysParams37"."kbn"=\'overseas_work_position\' and "SysParams37"."id"'
	), 'SysParams38'=>array( //ツバサ 2012-02-22 外国勤務2国名
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work2_nation"="SysParams38"."id" AND "SysParams38"."kbn"=\'country_id\' and "SysParams38"."id"'
	), 'SysParams39'=>array( //ツバサ 2012-02-22 外国勤務2期間
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work2_period"="SysParams39"."id" AND "SysParams39"."kbn"=\'overseas_work_period\' and "SysParams39"."id"'
	), 'SysParams40'=>array( //ツバサ 2012-02-22 外国勤務2目的
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work2_position"="SysParams40"."id" AND "SysParams40"."kbn"=\'overseas_work_position\' and "SysParams40"."id"'
	), 'SysParams41'=>array( //ツバサ 2012-02-22 外国勤務3国名
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work3_nation"="SysParams41"."id" AND "SysParams41"."kbn"=\'country_id\' and "SysParams41"."id"'
	), 'SysParams42'=>array( //ツバサ 2012-02-22 外国勤務3期間
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work3_period"="SysParams42"."id" AND "SysParams42"."kbn"=\'overseas_work_period\' and "SysParams42"."id"'
	), 'SysParams43'=>array( //ツバサ 2012-02-22 外国勤務3目的
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"overseas_work3_position"="SysParams43"."id" AND "SysParams43"."kbn"=\'overseas_work_position\' and "SysParams43"."id"'
	), 'SysParams50'=>array( //ツバサ 2012-02-22 TOEICレベル
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"toeic_level"="SysParams50"."id" AND "SysParams50"."kbn"=\'toeic_level\' and "SysParams50"."id"'
	), 'SysParams51'=>array( //就労ビザの国名 2012-02-22 TOEICレベル
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"work_visa_nation"="SysParams51"."id" AND "SysParams51"."kbn"=\'country_id\' and "SysParams51"."id"'
	), 'SysParams52'=>array( //ツバサ 2012-02-23 希望職種1
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_category1"="SysParams52"."id" AND "SysParams52"."kbn"=\'gyoshu_id\' and "SysParams52"."id"'
	), 'SysParams53'=>array( //ツバサ 2012-02-23 希望業種 大分類1
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_worktype1_big"="SysParams53"."id" AND "SysParams53"."kbn"=\'shokusyu_id\' and "SysParams53"."id"'
	), 'SysParams54'=>array( //ツバサ 2012-02-23 希望業種 小分類1
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_worktype1_small"="SysParams54"."id" AND "SysParams54"."kbn"=\'shokusyu_id\' and "SysParams54"."id"'
	), 'SysParams55'=>array( //ツバサ 2012-02-23 希望職種2
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_category2"="SysParams55"."id" AND "SysParams55"."kbn"=\'gyoshu_id\' and "SysParams55"."id"'
	), 'SysParams56'=>array( //ツバサ 2012-02-23 希望業種 大分類2
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_worktype2_big"="SysParams56"."id" AND "SysParams56"."kbn"=\'shokusyu_id\' and "SysParams56"."id"'
	), 'SysParams57'=>array( //ツバサ 2012-02-23 希望業種 小分類2
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_worktype2_small"="SysParams57"."id" AND "SysParams57"."kbn"=\'shokusyu_id\' and "SysParams57"."id"'
	), 'SysParams58'=>array( //ツバサ 2012-02-23 希望職種3
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_category3"="SysParams58"."id" AND "SysParams58"."kbn"=\'gyoshu_id\' and "SysParams58"."id"'
	), 'SysParams59'=>array( //ツバサ 2012-02-23 希望業種 大分類3
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_worktype3_big"="SysParams59"."id" AND "SysParams59"."kbn"=\'shokusyu_id\' and "SysParams59"."id"'
	), 'SysParams60'=>array( //ツバサ 2012-02-23 希望業種 小分類3
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_worktype3_small"="SysParams60"."id" AND "SysParams60"."kbn"=\'shokusyu_id\' and "SysParams60"."id"'
	), 'SysParams61'=>array( //ツバサ 2012-02-23 希望年収の単位
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"hope_income_cur"="SysParams61"."id" AND "SysParams61"."kbn"=\'income_cur\' and "SysParams61"."id"'
	), 'SysParams62'=>array( //@author wang.wei 2012/3/19 add 第一言語
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang1"="SysParams62"."id" AND "SysParams62"."kbn"=\'nationality_id\' and "SysParams62"."id"'
	), 'SysParams63'=>array( //@author wang.wei 2012/3/19 add 第一言語レベル
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang_level1"="SysParams63"."id" AND "SysParams63"."kbn"=\'language_level\' and "SysParams63"."id"'
	), 'SysParams64'=>array( //@author wang.wei 2012/3/19 add 第二言語
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang2"="SysParams64"."id" AND "SysParams64"."kbn"=\'nationality_id\' and "SysParams64"."id"'
	), 'SysParams65'=>array( //@author wang.wei 2012/3/19 add 第二言語レベル
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang_level2"="SysParams65"."id" AND "SysParams65"."kbn"=\'language_level\' and "SysParams65"."id"'
	), 'SysParams66'=>array( //@author wang.wei 2012/3/19 add 第三言語
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang3"="SysParams66"."id" AND "SysParams66"."kbn"=\'nationality_id\' and "SysParams66"."id"'
	), 'SysParams67'=>array( //@author wang.wei 2012/3/19 add 第三言語レベル
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang_level3"="SysParams67"."id" AND "SysParams67"."kbn"=\'language_level\' and "SysParams67"."id"'
	), 'SysParams68'=>array( //@author wang.wei 2012/3/19 add 第四言語
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang4"="SysParams68"."id" AND "SysParams68"."kbn"=\'nationality_id\' and "SysParams68"."id"'
	), 'SysParams69'=>array( //@author wang.wei 2012/3/19 add 第四言語レベル
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang_level4"="SysParams69"."id" AND "SysParams69"."kbn"=\'language_level\' and "SysParams69"."id"'
	), 'SysParams70'=>array( //@author wang.wei 2012/3/19 add 第五言語
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang5"="SysParams70"."id" AND "SysParams70"."kbn"=\'nationality_id\' and "SysParams70"."id"'
	), 'SysParams71'=>array( //@author wang.wei 2012/3/19 add 第五言語レベル
		'className'=>'SysParams', 'order'=>'', 'foreignKey'=>'"foreign_lang_level5"="SysParams71"."id" AND "SysParams71"."kbn"=\'language_level\' and "SysParams71"."id"'
	)
	);

	function Login_Valid($Valid, $params) {
		$message = '';
		$message .= $Valid->ErrorMsg($params, 'Member/login_id', 'required');
		$message .= $Valid->ErrorMsg($params, 'Member/login_pwd', 'required');
		return $message;
	}

	//@author zhufeng
	function searchMemberCondition($data) {
		$sql = " Member.deleted is null";
		$id = $data['Member']['id'];
		if(!empty($id)) {
			$sql .= " and Member.id = " . $id;
		}
		if(!empty($data['Member']['name_kana'])) {
			$sql .= " and Member.name_kana like '*" . $data['Member']['name_kana'] . "*' ";
		
		}
		if(!empty($data['Member']['email'])) {
			$sql .= " and Member.email like '*" . $data['Member']['email'] . "*' ";
		}
		if(!empty($data['Member']['nationality_id'])) {
			$nation = implode(',', $data['Member']['nationality_id']);
			
			$sql .= " and Member.nationality_id in (" . $nation . ") ";
		}
// 		if(!empty($data['Member']['grad_date_start'])) {
// 			$sql .= " and Member.grad_date >= " . $data['Member']['grad_date_start'];
// 		}
// 		if(!empty($data['Member']['grad_date_end'])) {
// 			$sql .= " and Member.grad_date<= " . $data['Member']['grad_date_end'];
// 		}
		if(!empty($data['Member']['create_date_start'])) {
			$sql .= " and Member.create >= " . $data['Member']['create_date_start'];
		}
		if(!empty($data['Member']['create_date_end'])) {
			$sql .= " and Member.create <= " . $data['Member']['create_date_end'];
		
		}
		if(!empty($data['Member']['mailmaga_flg'])) {
			$sql .= " and Member.mailmaga_flg =" . $data['Member']['mailmaga_flg'];
		}
		
		if(isset($_COOKIE['city_list'])) {
			$delete = array();
			$delete = split(',', $_COOKIE['city_list']);
			
			$m = implode(",", $delete);
			$sql .= " and SysParams3.id in (" . $m . ")";
		}
// 		if(isset($_COOKIE['interest_work_list'])) {
// 			$delete = array();
// 			$delete = split(",", $_COOKIE['interest_work_list']);
// 			$m = implode(",", $delete);
// 			$sql .= " and Member.interest_work_type_id1 in (" . $m . ") or Member.interest_work_type_id2 in(" . $m . ") or Member.interest_work_type_id3 in (" . $m . ")";
		
// 		}
// 		if(isset($_COOKIE['worked_list'])) {
// 			$delete = array();
// 			$delete = split(",", $_COOKIE['worked_list']);
// 			$m = implode(",", $delete);
// 			$sql .= " and Member.work_type_id1 in (" . $m . ") or Member.work_type_id2 in(" . $m . ") or Member.work_type_id3 in (" . $m . ")";
// 		}
// 		if(isset($_COOKIE['language_list'])) {
// 			$delete = array();
// 			$delete = split(",", $_COOKIE['language_list']);
// 			$m = implode(",", $delete);
// 			$sql .= " and Member.language_ch_bj_id in (" . $m . ") or Member.language_en_id in(" . $m . ") or Member.language_jp_id in (" . $m . ") or Member.language_other_id1 in (" . $m . ") or Member.language_other_id2 in (" . $m . ")";
// 		}
		return $sql;
	
	}

	//@author zhufeng
	function doDelete($id) {
		
		$sql = "update member_info Member set deleted=now() " . " where Member.id in ($id)";
		$this->query($sql);
	}

	//@author zhufeng
	function delete($data) {
		$sql = "update member_info Member set deleted=now() " . " where Member.id=" . $data;
		$this->query($sql);
	}

	//@author zhufeng
	function checkEmail($email, $email1, $canceltime = null) {
		$sql = "select * from member_info where email='" . $email . "' and member_role<>'withdraw' and deleted is null";
		$p = $this->query($sql);
		if(empty($p)) {
			$mem['Member']['email'] = $email1;
			
			$this->save($mem);
			return true;
		}else {
			$canceltime_validate = "select * from member_info " . "where " . //@author wangyuhua 2012-02-16 start	この行を注釈する
//"created<'".$canceltime."' and " .
			//@author wangyuhua 2012-02-16 end
			"member_role = 'visitor' and " . "email='" . $email . "' and " . "deleted is null";
			$re = $this->query($canceltime_validate);
			//注册时间超过规定时间，并未激活，允许重新注册
			if(!empty($re)) {
				$nowTime = strftime("%Y-%m-%d %X",time());
				$sql = "update member_info set created = '". $nowTime . "' where member_role = 'visitor' and " . "email='" . $email . "' and " . "deleted is null";
				$this->query($sql);
				return true;
			}else {
				return false;
			}
		}
	}

	function checkLogin_id($login_id) {
		$sql = "select * from member_info where login_id='" . $login_id . "' and deleted is null";
		return $this->query($sql);
	}

	//@author zhufeng
	function memValid($Valid, $data) {
		$message = '';
// 		$login_id = $this->checkLogin_id($data['Member']['login_id']);
// 		if(!empty($login_id)) {
// 			$message .= $Valid->tagErrorMsg('existlogin_id');
// 		}
		
		$message .= $Valid->ErrorMsg($data, 'Member/name_kanji', 'required');
		//		$message.=$Valid->ErrorMsg($data,'Member/name_kana','required');
		//		$message.=$Valid->ErrorMsg($data,'Member/name_kanji','must_one','Member','name_kana');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kanji', 'mbmaxlength', '20');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'mbmaxlength', '40');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'kana_roma');
		$message .= $Valid->ErrorMsg($data, 'Member/sex_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/email', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/email', 'email');
		$message .= $Valid->ErrorMsg($data, 'Member/email', 'mbmaxlength', '80');
		$message .= $Valid->ErrorMsg($data, 'Member/nationality_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/address_nation_id', 'required');
		
		$message .= $Valid->ErrorMsg($data, 'Member/address_nation_id', 'number');
		
		$message .= $Valid->ErrorMsg($data, 'Member/address_location_id', 'required');
		//		$message.=$Valid->ErrorMsg($data,'Member/birthday','required');
		if($Valid->ErrorMsg($data, 'Member/birthday', 'date')) {
			$message .= $Valid->tagErrorMsg('required', 'Member/birthday');
		}
		$message .= $Valid->ErrorMsg($data, 'Member/language_jp_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_ch_bj_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_en_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_other_note1', 'mbmaxlength', '20');
		$message .= $Valid->ErrorMsg($data, 'Member/language_other_note2', 'mbmaxlength', '20');
		if(!empty($data['Member']['language_other_id1'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/language_other_note1', 'required');
		}
		if(!empty($data['Member']['language_other_id2'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/language_other_note2', 'required');
		}
		if(!empty($data['Member']['login_pwd'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'minmaxlength', '6-20');
		}
		
		$message .= $Valid->ErrorMsg($data, 'Member/note', 'mbmaxlength', '3000');
		
		$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'confirm');
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_answer', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_answer', 'minlength', '1');
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_answer', 'mbmaxlength', '20');
		
		// by wang.wei 2012-3-1 add start
		$message .= $this->RegValidAdd($Valid, $data, 'update');
		// by wang.wei 2012-3-1 add end
		

		return $message;
	}

	//@author zhufeng
	function saveMem($data) {
		if(empty($data['Member']['login_pwd'])) {
			unset($data['Member']['login_pwd']);
		
		//			$id=$data['Member']['id'];
		//			$mem=$this->find("Member.id=".$id." and Member.deleted is null");
		//			$data['Member']['login_pwd']=$mem['Member']['login_pwd'];
		}else {
			$data['Member']['login_pwd'] = Md5($data['Member']['login_pwd']);
		}
		$this->save($data);
	
	}

	//@author zhufeng
	function savePassword($password, $id) {
		$sql = "update member_info set login_pwd='" . Md5($password) . "' where id=" . $id;
		$this->query($sql);
	}

	function saveremain($date) {
		$sql = "update member_info set remained='" . $date['Member']['remained'] . "',remain_key='" . $date['Member']['remain_key'] . "' where id=" . $date['Member']['id'];
		$this->query($sql);
	}

	//wang.wei update 2012/02/27
	function RegValid($Valid, $data) {
		
		$message = '';
		$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'minmaxlength', '6-20');
		$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'str_number');
		$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'htmlspecialchars');
		
		if(empty($message)){
			$login_id = $this->checkLogin_id($data['Member']['login_id']);
			if(!empty($login_id)) {
				$message .= $Valid->tagErrorMsg('exist', 
					'Member/login_id');
				//wang.wei add 2012/03/2
				$this->htmlValid[] = 'MemberLoginId';
			}
		}
		
		$message .= $Valid->ErrorMsg($data, 'Member/name_kanji', 'required');
		
		//		$message.=$Valid->ErrorMsg($data,'Member/name_kanji','must_one','Member','name_kana');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kanji', 'mbmaxlength', '20');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'mbmaxlength', '40');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'kana_roma');
		
		$message .= $Valid->ErrorMsg($data, 'Member/sex_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/nationality_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/address_nation_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/address_location_id', 'required');
		
		$message .= $Valid->ErrorMsg($data, 'Member/address_nation_id', 'number');
		
		$message .= $Valid->ErrorMsg($data, 'Member/address_location_other', 'mbmaxlength', '50');
		//		$message.=$Valid->ErrorMsg($data,'Member/birthday','required');
		

		if($Valid->ErrorMsg($data, 'Member/birthday', 'date')) {
			$message .= $Valid->tagErrorMsg('required', 'Member/birthday');
		}
		$message .= $Valid->ErrorMsg($data, 'Member/language_jp_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_ch_bj_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_en_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_other_note1', 'mbmaxlength', '20');
		$message .= $Valid->ErrorMsg($data, 'Member/language_other_note2', 'mbmaxlength', '20');
		if(!empty($data['Member']['language_other_id1'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/language_other_note1', 'required');
		}
		if(!empty($data['Member']['language_other_id2'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/language_other_note2', 'required');
		}
		
		$message .= $Valid->ErrorMsg($data, 'Member/note', 'mbmaxlength', '3000');
		$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'minmaxlength', '6-20');
		//$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'str_number');
		$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'confirm');
		
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_answer', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_answer', 'minlength', '3');
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_answer', 'mbmaxlength', '20');
		// by wang.wei 2012-2-27 add start
		$message .= $this->RegValidAdd($Valid, $data, 'insert');
		// by wang.wei 2012-2-27 add end
		return $message;
	}

	/*
	 * @author wang.wei add
	* 2012/02/28
	* */
	function RegValidAdd($Valid, $data, $op) {
		$message = '';
		if($op == 'update') {
			$message .= $Valid->ErrorMsg($data, 'Member/email', 'allRequired');
			$message .= $Valid->ErrorMsg($data, 'Member/email', 'email');
			$message .= $Valid->ErrorMsg($data, 'Member/email', 'mbmaxlength', '80');
			if(!$Valid->allRequired($data['Member']['email']) || !$Valid->email($data['Member']['email']) || !$Valid->mbmaxlength($data['Member']['email'], 80)) {
				$this->htmlValid[] = 'MemberEmail';
			}
			//wang.wei add 2012/3/31
			$message .= $Valid->ErrorMsg($data, 'Member/public_profile_flg', 'required');
		}elseif($op == 'insert') {
			$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'required');
			$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'minmaxlength', '6-20');
			$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'str_number');
			if(!$Valid->password_input_member($data['Member']['login_pwd']) || !$Valid->required($data['Member']['login_pwd']) || !$Valid->minmaxlength($data['Member']['login_pwd'], '6-20')
				|| !$Valid->htmlspecialchars($data['Member']['login_id'])) {
				$this->htmlValid[] = 'MemberLoginPwd';
			}
			if(!$Valid->required($data['Member']['login_id']) || !$Valid->minmaxlength($data['Member']['login_id'], '6-20') || !$Valid->str_number($data['Member']['login_id'])
				|| !$Valid->htmlspecialchars($data['Member']['login_id'])) {
				$this->htmlValid[] = 'MemberLoginId';
			}
			//wang.wei add 2012/3/31
			$message .= $Valid->ErrorMsg($data, 'Member/public_profile_flg', 'required');
		}elseif($op == 'order_update'){
			$message .= $Valid->ErrorMsg($data, 'Member/email', 'allRequired');
			$message .= $Valid->ErrorMsg($data, 'Member/email', 'email');
			$message .= $Valid->ErrorMsg($data, 'Member/email', 'mbmaxlength', '80');
			if(!$Valid->allRequired($data['Member']['email']) || !$Valid->email($data['Member']['email']) || !$Valid->mbmaxlength($data['Member']['email'], 80)) {
				$this->htmlValid[] = 'MemberEmail';
			}
		}
		// by wang.wei 2012-2-27 add start
		if(!empty($data['Member']['login_pwd'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'password_input_member');
			$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'htmlspecialchars');
			if(!$Valid->password_input_member($data['Member']['login_pwd']) || !$Valid->minmaxlength($data['Member']['login_pwd'], '6-20')
				|| !$Valid->htmlspecialchars($data['Member']['login_pwd'])) {
				$this->htmlValid[] = 'MemberLoginPwd';
			}
		}
		
		if(!empty($data['Member']['login_pwd_confirm'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/login_pwd_confirm', 'htmlspecialchars');
			if(!$Valid->htmlspecialchars($data['Member']['login_pwd_confirm'])) {
				$this->htmlValid[] = 'MemberLoginPwdConfirm';
			}
		}
		
		//$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'required');
		//$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'minmaxlength','6-20');
		//$message .= $Valid->ErrorMsg($data, 'Member/login_id', 'str_number');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'mbmaxlength', '250');
		$message .= $Valid->ErrorMsg($data, 'Member/address_location_other', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/address_location_other', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/tel', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/tel', 'mbmaxlength', '20');
		$message .= $Valid->ErrorMsg($data, 'Member/toeic_level', 'number');
		$message .= $Valid->ErrorMsg($data, 'Member/toeic_level', 'maxlength', '9');
		$message .= $Valid->ErrorMsg($data, 'Member/toeic_qualification', 'mbmaxlength', '150');
		$message .= $Valid->ErrorMsg($data, 'Member/qualification', 'mbmaxlength', '150');
		$message .= $Valid->ErrorMsg($data, 'Member/work_status_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'MemberEducation/edu_degree', 'required');
		
		//特殊文字のチェック
		$message .= $Valid->ErrorMsg($data, 'Member/pwd_remain_answer', 'htmlspecialchars');
		
		if($data['Member']['nationality_id'] == '4') {
			$message .= $Valid->ErrorMsg($data, 'Member/other_language', 'required');
			$message .= $Valid->ErrorMsg($data, 'Member/other_language', 'mbmaxlength', '40');
		}
		
		for($i = 1; $i <= $data['Member']['member_overseas_edu_count']; $i++) {
			if(!empty($data['Member']['overseas_edu' . $i . '_nation'])) {
				$message .= $Valid->ErrorMsg($data, 'Member/overseas_edu' . $i . '_nation', 'required');
				$message .= $Valid->ErrorMsg($data, 'Member/overseas_edu' . $i . '_period', 'required');
				$message .= $Valid->ErrorMsg($data, 'Member/overseas_edu' . $i . '_purpose', 'required');
			}
		}
		for($i = 1; $i <= $data['Member']['member_overseas_work_count']; $i++) {
			if(!empty($data['Member']['overseas_work' . $i . '_nation'])) {
				$message .= $Valid->ErrorMsg($data, 'Member/overseas_work' . $i . '_nation', 'required');
				$message .= $Valid->ErrorMsg($data, 'Member/overseas_work' . $i . '_period', 'required');
				$message .= $Valid->ErrorMsg($data, 'Member/overseas_work' . $i . '_position', 'required');
			}
		}
		//@author wang.wei 2012/3/19 update start
		for($i = 1; $i <= $data['Member']['member_lang_count']; $i++) {
			if(!empty($data['Member']['lang' . $i])) {
				$message .= $Valid->ErrorMsg($data, 'Member/foreign_lang' . $i, 'required');
				$message .= $Valid->ErrorMsg($data, 'Member/foreign_lang_level' . $i, 'required');
			}
		}
		//@author wang.wei 2012/3/19 update end
		
		//@author wang.wei 2012/3/21 update
		for($i = 1; $i <= $data['Member']['member_hope_worktype_count']; $i++) {
			if(!empty($data['Member']['hope_category' . $i])) {
				//$message .= $Valid->ErrorMsg($data, 'Member/hope_worktype' . $i . '_big', 'required');
				//$message .= $Valid->ErrorMsg($data, 'Member/hope_worktype' . $i . '_small', 'required');
				$message .= $Valid->ErrorMsg($data, 'Member/hope_worktype' . $i . '_big', 'number');
			}
		} 
		for($i = 0; $i < count($data['MemberExpWorktype']['exp_category']); $i++) {
			if(!empty($data['MemberExpWorktype']['exp_category'][$i])) {
				$validdata['MemberExpWorktype']['exp_worktype_big'] = $data['MemberExpWorktype']['exp_worktype_big'][$i];
				$validdata['MemberExpWorktype']['exp_worktype_small'] = $data['MemberExpWorktype']['exp_worktype_small'][$i];
				$validdata['MemberExpWorktype']['exp_year'] = $data['MemberExpWorktype']['exp_year'][$i];
				$message .= $Valid->ErrorMsg($validdata, 'MemberExpWorktype/exp_worktype_big', 'required');
				$message .= $Valid->ErrorMsg($validdata, 'MemberExpWorktype/exp_worktype_big', 'number');
				
				$message .= $Valid->ErrorMsg($validdata, 'MemberExpWorktype/exp_worktype_small', 'required');
				$message .= $Valid->ErrorMsg($validdata, 'MemberExpWorktype/exp_year', 'required');
				$message .= $Valid->ErrorMsg($validdata, 'MemberExpWorktype/exp_year', 'htmlspecialchars');
			}
		}
		if($data['Member']['work_visa_flg'] == '0') {
			$message .= $Valid->ErrorMsg($data, 'Member/work_visa_nation', 'required');
		}
		if($data['Member']['hope_income_flg'] == '2') {
			/* wang.wei 2012/12/10 update start */
			//$message .= $Valid->ErrorMsg($data, 'Member/hope_income', 'required');
			if(empty($data['Member']['hope_income']) && empty($data['Member']['hope_income_to'])){
				$msg = $Valid->error('member_income_both');
				$message .= " " . $msg . "<br/>";
				$this->htmlValid[] = 'MemberHopeIncome';
				$this->htmlValid[] = 'MemberHopeIncomeTo';
			}
			if(!empty($data['Member']['hope_income']) && !empty($data['Member']['hope_income_to'])){
				if($data['Member']['hope_income'] > $data['Member']['hope_income_to']){
					$msg = $Valid->error('member_income_both_compare');
					$message .= " " . $msg . "<br/>";
					$this->htmlValid[] = 'MemberHopeIncome';
					$this->htmlValid[] = 'MemberHopeIncomeTo';
				}
			}
			/* wang.wei 2012/12/10 update end */
			
			$message .= $Valid->ErrorMsg($data, 'Member/hope_income', 'number');
			$message .= $Valid->ErrorMsg($data, 'Member/hope_income', 'maxlength', '9');
			$message .= $Valid->ErrorMsg($data, 'Member/hope_income_cur', 'required');

			//wang.wei 2012/5/8 add start
			if($data['Member']['hope_income_cur'] == '1'){
				if((empty($data['Member']['hope_income']) && $data['Member']['hope_income_to'] < '1000000') || (empty($data['Member']['hope_income_to']) && $data['Member']['hope_income'] < '1000000')){
					$msg = $Valid->error('member_income');
					$msg = r('{0}','円',$msg);
					$msg = r('{1}',number_format('1000000'),$msg);
					$message .= " " . $msg . "<br/>";
					$this->htmlValid[] = empty($data['Member']['hope_income']) ? 'MemberHopeIncomeTo' : 'MemberHopeIncome';
				}
			}else if($data['Member']['hope_income_cur'] == '2'){
				if((empty($data['Member']['hope_income']) && $data['Member']['hope_income_to'] < '10000') || (empty($data['Member']['hope_income_to']) && $data['Member']['hope_income'] < '10000')){
					$msg = $Valid->error('member_income');
					$msg = r('{0}','元',$msg);
					$msg = r('{1}',number_format('10000'),$msg);
					$message .= " " . $msg . "<br/>";
					$this->htmlValid[] = empty($data['Member']['hope_income']) ? 'MemberHopeIncomeTo' : 'MemberHopeIncome';
				}
			}else if($data['Member']['hope_income_cur'] == '3'){
				if((empty($data['Member']['hope_income']) && $data['Member']['hope_income_to'] < '10000') || (empty($data['Member']['hope_income_to']) && $data['Member']['hope_income'] < '10000')){
					$msg = $Valid->error('member_income');
					$msg = r('{0}','ドル',$msg);
					$msg = r('{1}',number_format('10000'),$msg);
					$message .= " " . $msg . "<br/>";
					$this->htmlValid[] = empty($data['Member']['hope_income']) ? 'MemberHopeIncomeTo' : 'MemberHopeIncome';
				}
			}
			//wang.wei 2012/5/8 add end
			if(!$Valid->number($data['Member']['hope_income']) || !$Valid->maxlength($data['Member']['hope_income'], 9)) {
				$this->htmlValid[] = 'MemberHopeIncome';
			}
			if(!$Valid->number($data['Member']['hope_income_to']) || !$Valid->maxlength($data['Member']['hope_income_to'],9)){
				$this->htmlValid[] = 'MemberHopeIncomeTo';
			}
		}
		
		if(!$Valid->required($data['Member']['name_kanji']) || !$Valid->mbmaxlength($data['Member']['name_kanji'], 20)) {
			$this->htmlValid[] = 'MemberNameKanji';
		}
		if(!$Valid->required($data['Member']['name_kana']) || !$Valid->kana_roma($data['Member']['name_kana']) || !$Valid->mbmaxlength($data['Member']['name_kana'], 40)) {
			$this->htmlValid[] = 'MemberNameKana';
		}
		if(!$Valid->required($data['Member']['address_location_other']) || !$Valid->mbmaxlength($data['Member']['address_location_other'], 50)) {
			$this->htmlValid[] = 'MemberAddressLocationOther';
		}
		if(!$Valid->required($data['Member']['tel']) || !$Valid->mbmaxlength($data['Member']['tel'], 20)) {
			$this->htmlValid[] = 'MemberTel';
		}
		if(!$Valid->required($data['Member']['pwd_remain_answer']) || !$Valid->minlength($data['Member']['pwd_remain_answer'], '3') || !$Valid->mbmaxlength($data['Member']['pwd_remain_answer'], 20)
			|| !$Valid->htmlspecialchars($data['Member']['pwd_remain_answer'])) {
			$this->htmlValid[] = 'MemberPwdRemainAnswer';
		}
		if(!$Valid->number($data['Member']['toeic_level']) || !$Valid->mbmaxlength($data['Member']['toeic_level'], 9)) {
			$this->htmlValid[] = 'MemberToeicLevel';
		}
		//wang.wei add 2012/4/5 start
		if(!$Valid->mbmaxlength($data['Member']['toeic_qualification'], 150)) {
			$this->htmlValid[] = 'MemberToeicQualification';
		}
		if(!$Valid->mbmaxlength($data['Member']['qualification'], 150)) {
			$this->htmlValid[] = 'MemberQualification';
		}
		//wang.wei add 2012/4/5 end
		return $message;
	}

	//@author zhufeng  
	function memValid2($Valid, $data) {
		$message = '';
// 		$login_id = $this->checkLogin_id($data['Member']['login_id']);
// 		if(!empty($login_id)) {
// 			$message .= $Valid->tagErrorMsg('existlogin_id');
// 		}
		
		$message .= $Valid->ErrorMsg($data, 'Member/name_kanji', 'required');
		//		$message.=$Valid->ErrorMsg($data,'Member/name_kana','required');
		//		$message.=$Valid->ErrorMsg($data,'Member/name_kanji','must_one','Member','name_kana');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kanji', 'mbmaxlength', '20');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'mbmaxlength', '40');
		$message .= $Valid->ErrorMsg($data, 'Member/name_kana', 'kana_roma');
		$message .= $Valid->ErrorMsg($data, 'Member/sex_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/email', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/email', 'email');
		$message .= $Valid->ErrorMsg($data, 'Member/email', 'mbmaxlength', '80');
		$message .= $Valid->ErrorMsg($data, 'Member/nationality_id', 'required');
		$message .= $Valid->ErrorMsg($data, 'Member/address_nation_id', 'required');
		
		$message .= $Valid->ErrorMsg($data, 'Member/address_nation_id', 'number');
		
		$message .= $Valid->ErrorMsg($data, 'Member/address_location_id', 'required');
		//		$message.=$Valid->ErrorMsg($data,'Member/birthday','required');
		if($Valid->ErrorMsg($data, 'Member/birthday', 'date')) {
			$message .= $Valid->tagErrorMsg('required', 'Member/birthday');
		}
		$message .= $Valid->ErrorMsg($data, 'Member/language_jp_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_ch_bj_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_en_note', 'mbmaxlength', '50');
		$message .= $Valid->ErrorMsg($data, 'Member/language_other_note1', 'mbmaxlength', '20');
		$message .= $Valid->ErrorMsg($data, 'Member/language_other_note2', 'mbmaxlength', '20');
		if(!empty($data['Member']['language_other_id1'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/language_other_note1', 'required');
		}
		if(!empty($data['Member']['language_other_id2'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/language_other_note2', 'required');
		}
		if(!empty($data['Member']['login_pwd'])) {
			$message .= $Valid->ErrorMsg($data, 'Member/login_pwd', 'minmaxlength', '6-20');
		}
		
		$message .= $Valid->ErrorMsg($data, 'Member/note', 'mbmaxlength', '3000');
		
		// by wang.wei 2012-3-1 add start
		$message .= $this->RegValidAdd($Valid, $data, 'order_update');
		// by wang.wei 2012-3-1 add end
		

		return $message;
	}
	

	function updateLastLogin($data) {
		$sql = "update member_info set last_login_data='" . $data['Member']['last_login_data'] . "' where id=" . $data['Member']['id'];
		$this->query($sql);
	}

	function emailValid($Valid, $data) {
		// @author wang.wei 2012/3/15 update start
		if(!isset($data['Member']['email']) || empty($data['Member']['email'])) {
			return null;
		}
		// @author wang.wei 2012/3/15 update end
		
		$encrypt = new EncryptComponent();
		$encrypt->encode($data['Member']['email']);
		$condition = "\"Member\".email='" . $data['Member']['email'] . "'";
		if(isset($data['Member']['id']) && !empty($data['Member']['id'])) {
			$condition .= " AND \"Member\".id != " . $data['Member']['id'] . " AND \"Member\".deleted is null";
		}
		$this->belongsTo = array();
		$data = $this->find($condition);
		if(empty($data)) {
			return null;
		}else {
			return $Valid->tagErrorMsg("exist", 'Member/email');
		}
	}

	//@author wangyuhua 2012/2/23 add start
	function getSearchInfo($member_id) {
		$allsql = "select a.*,b.exp_category,b.exp_worktype_big,b.exp_worktype_small,b.exp_year,c.edu_degree from " . "member_info a left join member_exp_worktype_info b on a.id=b.member_id and b.deleted is null left join " . "(select edu.* from  member_education_info edu join	" . "(select  member_id,min(id) from " . "member_education_info where deleted is null group by member_id " . ") m  on edu.member_id = m.member_id  ) as  c on c.member_id = a.id and c.deleted is null where a.id = '" . $member_id . "' and a.deleted is null";
		$data = $this->query($allsql);
		$this->decoded($data);
		return $data;
	}

	/**
	 * @auth yangjie
	 * @desc 数据解密方法
	 */
	function decoded(&$data) {
		if(isset($this->encrypt_col) && !empty($this->encrypt_col)) {
			foreach ( $data as $key => $val ) {
				if(!empty($key)) { //解密一条记录
					$this->decoded_array($data);
					break;
				}
				foreach ( $val as $k => $v ) { //解密多条记录
					$this->decoded_array($data[$key][$key]);
				}
			}
		}
	}

	/**
	 * @auth yangjie
	 * @desc 数组解密方法
	 */
	function decoded_array(&$data) {
		if(!empty($this->encrypt_col)) {
			foreach ( $this->encrypt_col as $key => $val ) {
				$encrypt = new EncryptComponent();
				$encrypt->decode($data[$val]);
			}
		}
	}

	/*
	 * @author wang.wei add
	* 2012/02/29
	* */
	function updateMemberPoint($id, $completion_point) {
		$sql = "update member_info Member set completion_point=$completion_point " . " where Member.id in ($id)";
		$this->query($sql);
	}
	
	/**
	 * MissLoginTimeをセットする
	 *
	 * create:2012-03-10 ツバサ（エスワイシステム）
	 * updata:
	 * */
	function updateMissLoginTime($id, $val=null) {
		$sql = "UPDATE member_info SET last_miss_login_time = '$val' WHERE id = $id";
		$this->query($sql);
	}

	/**
	 *
	 * add 2012/4/7
	 * @author wang.wei
	 * @param member_id
	 * @param type_arr
	 *
	 **/
	function getCheckLastChangePwdTime($member_id, $type_arr){
		list($type,$num) = explode(',', $type_arr);
		if($type == 'month'){
			$sqlw = " WHERE To_number(To_char(( Now() - last_pwd_modified ), 'DD'), '999999999') >= ".Sanitize::sql($num*30)." ";
		}
		if($type == 'year'){
			$sqlw = " WHERE To_number(To_char((AGE(Now(), last_pwd_modified)), 'YYYY'), '999999999') >= ".Sanitize::sql($num)." ";
		}
		$sql = "SELECT id FROM member_info ";
		$sql .= $sqlw;
		$sql .= " AND id = ".Sanitize::sql($member_id)." ";
	
		$data = $this->query($sql);
	
		list(list($data)) = $data;
		if($data['id'] == $member_id){
			return false;
		}else {
			return true;
		}
	}
	
	/**
	 *
	 * add 2012/4/7
	 * @author wang.wei
	 * @param member_id
	 * @param con
	 *
	 **/
	function updateMemberCon($member_id, $con){
		$sql= " UPDATE member_info SET ".$con." WHERE id IN (".Sanitize::sql($member_id).")";
		$this->query($sql);
	}
	
}

?>